perm filename MOVE[ALS,ALS] blob sn#181944 filedate 1975-10-23 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	Specifications for a string moving command. 
C00012 00003	    Some ideas on implimentation. 
C00017 ENDMK
C⊗;
Specifications for a string moving command. 

   A string  of words can  be extracted or  copied by placing  the line-
editor  cursor at the  desired starting position  and then  by giving an
appropiate command. Two cases are to be distinguished, the one in which
a + or a - symbol preceedes the initial command and the second when an
unsigned argument (with 1 as a default value) is used.  In the first case
the line of text is to be split into two portions, while in the second
case the number specifies the number of words that are to be extracted
or copied.

Relative case (with a sign typed)
	The positive sign implies that the line is to be split with the
text to the right starting at the cursor position to be put into a special
attach buffer and shown below the original line in a position so that
additional lines may be added. These additional lines may be entire lines
and finally one may move the cursor out into a line and give the extract
or copy instruction with a negative sign to append the left portion of the
then current line up to but not including the cursor position.

Unsigned case with an initial argument (or a default value of 1)
	In this case the specifief number of words are to be extracted
or copied. If the cursor is
under a delimiter the string will begin with  a space and no terminating
space will be  included while if the cursor is under the first character
of a word, the string will  begin with this character and a  terminating
space will be included.  Should the line not  be in the line-editor then
a space will be  removed from the remaining text and placed at the start
of the string. The disposition of the attached or copied string is
specified by an argument that follows the command.
   If  the  command  is terminated  by  a  carriage  return  without  an
interposed number, the  extracted or copied string is placed immediately
above the line from which it came.  If the control key is used  with the
carriage return then the removed or copied string is left ATTACHED. 

   If a  number is  typed between  the command  symbol and the  carriage
return  then the string is  moved the specified number  of words, to the
right (with a maximum to the end of the line) for a positive  number and
to the left  for a negative number  (with the limit set by  the start of
the  line. In this case typing the  carriage return with the control key
will cause the the line editor to be reentered and the cursor positioned
under the first character of the moved string. 

   Strings may also be inserted into a line by locating the string above
the  line into which it  is to be inserted,  positioning the line-editor
cursor under the  desired location in  the desired  line and giving  the
appropiate command. 

   A word is defined  in this connection as any  collection of printable
characters that is delimited by, the start of a line, spaces, tabs, or a
carraige return.  

   A posible choice of symbols might be ∨ for  extract, = for copy and ∧
for insert.  These symbols are used in this explanation but they may, of
course, be replaced by any desired set. 

   Commands

⊗4⊗∨<CR>     Remove 4 words starting at the line-editor cursor position,
and place them just above the line from which they came.

⊗4⊗=<CR>     Copy 4 words starting at the line-editor cursor position as
a separate string and position the string just above the line from which
it was copied. 

Note: replacing ∨ with the command symbol = will convert any of the
following instructions from a remove to a copy instruction.

⊗5⊗∨α<CR>     Remove 5 words starting at the line-editor cursor position
ATTACH the string and show it just above the line from which it came.

⊗2⊗∨3<CR>    Pick up 2 words starting at the line-editor cursor position
and move them 3 words to the right leaving the line-editor. 

⊗2⊗∨-3<CR>   Pick up 2 words starting at the line-editor cursor position
and move them 3 words to the left leaving the line-editor. 

⊗2⊗∨3α<CR>  Pick up 2 words starting at the line-editor cursor position,
move  them 3 words  to the  right and reenter  the line editor  with the
cursor under the first character of the moved string. 

⊗2⊗∨-3α<CR> Pick up 2 words starting at the line-editor cursor position,
move  them 3  words to  the left and  reenter the  line editor  with the
cursor under the first character of the moved string. 

⊗∧<CR>    Insert the string,  from  the line immediately  above  the
current line, at the position shown by the line-editor cursor (or at the
beginning of the line if this line is not in the line-editor). 
If the attach buffer contains more than one line of text and if either
the extended left half of the first line or the augmented last line
from the buffer exceeds the line limit set in the preset justification
limits then justify the lines under consideration.

The Q-register approach

Another way to cut the cookie would be to create some Q registers into which
one can put things and from which one can copy. One would then have commands
to load a specific Q-register, to append material to it and to copy its 
contents either with out erasing it or with deletion. Its contents should be 
insertable into a line of text at any desired point or between lines as
desired.

The load command could have a different meaning depending on whether or no 
one was in the line editor. If not in the line editor an argument would refer
to the number of words to be loaded or appended while when in the line editor
it could refer to the number of words. A further refinement might be to permit
the specification of either words or characters in the latter case, perhaps
differentiated by a letter following the command. Or for still greater
generality one could allow the specification of lines, words, or characters
in all cases. If in the line editor the remains of the current line starting
at the cursor would count as the first line. Still another variation would be
to have the initial argument refer to the Q-register number and to allow
following arguments with the letters L, W, or C to specify lines, words, and
characters.

Example: ⊗3⊗∨2L3W4C<CR>	meaning, starting at the cursor position load register 3
with 2 lines (counting the rest of this line as 1) then 3 words and 4 charecters
from the next line.
    Some ideas on implimentation. 

STRING:	MOVEM A,SARG		;Save argument as word count
	HRLZM B,SCHR
	HRRM C,SCHR
	SETZB A,C
	PUSHJ P,TYI
	JRST MOCCN2
	CAIE C,"-"
	JRST .+4
	TRO F,NEG
MOVCNT:	PUSHJ P,TYI
	JRST MOVCN2
	CAIG C,71
	CAIGE C,60
	JRST MOVCN2
	IMULI A,12
	ADDI A,-"0"(C)
	CAILE A,=60		;Allow only 60 words, let's not be foolish
	MOVEI A,=60
	JRST MOVCNT

MOVCN2:	MOVEM C,CSAVE		;Save terminating activation character
	MOVEM A,STRMOV		;If non-zero, the move number
	SETZM TYOPNT
	HRRZ E,ARRLIN		;Get line location in free storage
	MOVEI H,LLDESC(E)
	TLO H,440700		;H points to text in free storage
	MOVE I,[440700,7,BUF]	;Collect remaining part of line in BUF
	MOVE D,[440700,7,BUF2]	;Collect string in BUF2
	TRNN F,EDITM		;In line edit mode?
	JRST [MOVEI C,40↔IDPB C,D↔JRST STRIN1]	;No
	MOVE B,EDCNM		;So positioning will be right in first line
	MOVE Q,EDPOS		;Get location of cursor
	ADD Q,EDTBS		;TAB's were not counted in EDPOS
	ADD Q,EDTBS		;and they are duplicated
	JUMPE Q,STRIN1		;It could be at the start
	ILDB C,H		;We want H to point to starting position
	CAIN C,11		;Is it a TAB?
	JRST [SOS Q,
	      ILDB C,H
	      CAIN C,11
	      JRST .-3		;Eat to next TAB
	      JRST STRIN0]
	CAIN C,40
STRIN0:	AOS STRCNT		;Count the number of words to the left of cursor
	IDPB C,I		;Save it in BUF
	SOJG Q,.-4
STRIN1:
	ILDB C,H		;Look at new first character
	CAIN C,15		;Or a CR?
	JRST STRIN2		;We are at the end of the line
	IDPB C,D		;Save it in BUF2
	CAIN C,40		;Is it a space
	SOJLE A,STRIN2		;We have the required number of words
	JRST STRIN1

STRIN2:	MOVEI C,0
	IDPB C,H		;Terminate string with a NUL
	SKIPGE TT,STRMOV	;Get moving direction and amount
	JRST STRIN10		;Going to the left
STRIN3:	CAIN C,15		;Are we already at the end of the line?
	JRST STRIN4		;Yes
STRI3A:ILDB C,H		;No, so copy the required number of words
	CAIE C,0
	CAIN C,15		;Watch out for the end of the line
	JRST STRIN5		;We are there
	IDPB C,I		;Put it into BUF
	CAIN C,40		;Are we at a word end?
	SOJG TT,STRIN3
	JRST STRIN5

STRIN4:	MOVEI C,40		;We'ill need a space in this case
	IDPB C,H
STRIN5:	MOVE D,[440700,7,BUF2]	;Now to get the string
STRIN6:	ILDB C,D
	CAIN C,0		;Are we at the end?
	JRST STRIN7		;Yes
	IDPB C,I
	JRST STRIN6

STRIN7:	ILDB C,H		;Now finish with the original text
	CAIE C,0		;Look out for NULs
	CAIN C,15		;Are we at the end?
	JRST STRIN8
	IDPB C,I
	JRST STRIN7

STRI2:	MOVEI H,LLDESC(E)
	TLO H,440700
	ADD TT,STRCNT		;To find the number of words to pass
	JUMPLE TT,STRIN5
	JRST STRI3A